<%#
 Copyright 2013-2019 the original author or authors from the JHipster project.

 This file is part of the JHipster project, see https://www.jhipster.tech/
 for more information.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-%>
AWSTemplateFormatVersion: 2010-09-09
Parameters:
  applicationStackS3Bucket:
    Type: String
    Description: Name of the S3 bucket containing the application.template.yml template file
    Default: <%= aws.s3BucketName %>
<% for (app of appConfigs) { %>  <%= app.baseName %>DBPassword:
    Type: String
    Description: Aurora master database password for <%= app.baseName %>
    NoEcho: true
<%} %>
  shouldDeployService:
    Type: String
    Description: Should the ECS service be initialised
    AllowedValues:
        - true
        - false
    Default: false
Resources:
<% for (app of appConfigs) { %>  <%= app.baseName %>:
    Type: 'AWS::CloudFormation::Stack'
    Properties:
      Parameters:
        parentStackName: !Ref AWS::StackName
        repositoryName: <%= aws.cloudFormationName%>/<%= app.baseName %>
        shouldDeployService: !Ref shouldDeployService
        databasePassword: !Ref <%= app.baseName %>DBPassword
      TemplateURL: !Join [ '', [ 'https://s3.amazonaws.com/',!Ref applicationStackS3Bucket, '/<%= app.baseName %>.template.yml'] ]
<%} %>
Outputs:
<% for (app of appConfigs) { %>  LoadBalancerOutput<%= app.baseName %>:
    Description: The external DNS address of the load-balancers
    Value: !GetAtt <%= app.baseName %>.Outputs.LoadBalancerOutput
<%} %>
